package com.EpidemicPrevention.service;

import com.EpidemicPrevention.mapper.ExceedMapper;

import com.EpidemicPrevention.pojo.Exceed;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExceedServiceImpl implements ExceedService{

    @Autowired
    private ExceedMapper exceedMapper;

    @Override
    public JSON addExceed(Exceed exceed) {
        JSONObject json = new JSONObject();

        int code =0;
        code = exceedMapper.addExceed(exceed);
        if (code ==1){
            json.put("msg","添加成功");
            json.put("code",1);
        }else {
            json.put("msg","添加失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON deleteExceed(int e_id) {
        JSONObject json = new JSONObject();
        int code =0;
        code = exceedMapper.deleteExceed(e_id);
        if (code ==1){
            json.put("msg","删除成功");
            json.put("code",1);
        }else {
            json.put("msg","删除失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON updateExceed(Exceed exceed) {
        JSONObject json = new JSONObject();

        int code=0;
        code=exceedMapper.updateExceed(exceed);
        if (code==1){
            json.put("msg","修改入校信息成功");
            json.put("code",1);
        }else{
            json.put("msg","修改入校信息失败");
            json.put("code",0);
        }

        return json;
    }

    @Override
    public List<Exceed> queryExceed (int page, int limit,String Keyword) {
        return exceedMapper.queryExceed(page, limit,null);
    }
    @Override
    public List<Exceed> selectWhereExceed() {
        return exceedMapper.selectWhereExceed();
    }



}
